PLC BLOG | Codesys Plc timer
Share on Facebook Share On Twitter Share on LinkedIn Share on Whatsapp


lg-12 col-12 fb-share-button">

Share on Facebook

Share on twitter

Share on Whats-App

codesys ladder programming timer: TOF,TON and TP

in codesys ladder programming have three types of timer, pulse timer TP, turn-off delay TOF and turn on delay timer TON, input IN and preset time (PT) are input and elapsed time (ET) and output Q are output.To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor).

instances is important when you define any type of function block, By declaring the function Block(FB) you create a copy of the original FB. This copy is saved under instance name. A separate data area is reserved for this copy.diffrent timer instace name and type


TP, a pulse timer

The function block TP allows you to program a pulse timer with a defined clock period. input IN and Preset time PT are input variables of the BOOL and TIME data types respectively. output Q and elapse time ET are output variables of the BOOL and TIME data types. when IN is False or set to 0 then Q is FALSE and set to 0 and ET is 0. if IN set to true or set to 1 then timer begin to be counted in milliseconds until PT = ET then remain constant. Q is TRUE or set to 1 if IN is set to TRUE and ET is less than or equal to PT. Otherwise it is FALSE.


TOF: turn-off delay

The function block TOF allows you to program a switch-off delay. in TOF input variables are IN and PT data type BOOL and TIME. Q and E are output variables BOOL and TIME are data types. If IN is TRUE, the outputs are TRUE. when IN becomes true to false, timer start counting in milliseconds until its value is equal to PT, then It will then remain constant. Q is FALSE when IN is FALSE and ET equal to or less then PT. Otherwise it is TRUE.


TON:turn-on delay

The function block Timer On Delay implements a turn-on delay.TON(IN, PT, Q, ET) means: IN and PT are input variables of the BOOL and TIME data types respectively. Q and ET are output variables of the BOOL and TIME data types respectively. If IN is FALSE , Q is FALSE and ET is 0. As soon as IN becomes TRUE, the time will begin to be counted in milliseconds until ET = PT then remain constant and output Q is TRUE. Q is True PT = ET Otherwise it is FALSE. Thus, Q has a rising edge when the time indicated in PT in milliseconds has run out.


Time Constant

TIME constants can be declared in CoDeSys. These are generally used to operate the timer in the standard library. A TIME constant is always made up of an initial "t" or "T" and a number sign "#".


convert another data type into time

so if you want to convert int, DINT, DWORD etc. in TIME format so you can use convert block like DATATYPE_TO TIME and if you want to conver time into another data type use TIME_TO_DATATYPE.

conversion of time value to other data types

for conversion of time value into another data type used following blocks "NOTE:_in codesys you can convert more data types into time but above are useful in industry purpose."


example of timer

consider a simple example, in this programming example timer input bit (IN) is depended on equal compare block output. compare block compare preset (PT) and elapsed time(ET) value if both are equal output of compare block set to true this condition stop timer as soon as when timer stop estimate timer(ET) value set to 0 and not equal to preset value so output of compare block set to false then timer again start from begining.